package org.mech.sefer.client.ui.spring.task;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.Validate;
import org.springframework.stereotype.Component;

/**
 * <p>
 * The TaskRegistry is simple container for reflection tasks. They are register here under generated key.
 * </p>
 * <p>
 * Date: 26.4.2012 10:35:07
 * </p>
 *
 * @author martin.krajc
 */
@Component("taskRegistry")
@SuppressWarnings("rawtypes")
public class TaskRegistry {
	
	private Map<String, ReflectionTask> taskMap = new HashMap<String, ReflectionTask>();

	public void registerTask(String name, ReflectionTask task){
		Validate.notNull(name);
		Validate.notNull(task);
		
		taskMap.put(name, task);
	}
	
	public ReflectionTask getTask(String name){
		return taskMap.get(name);
	}
	
	public String createKey(String method, Class beanClass){
		return beanClass.getName() + "." + method;
	}
}
